<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>西瓜后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/lib/zTree/css/zTree.css" type="text/css">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" type="text/css">
    <link rel="stylesheet" href="../../../layuiadmin/lib/zTree/css/awesomeStyle/awesome.css" type="text/css">
    <link rel="stylesheet" href="../../../layuiadmin/lib/zTree/css/awesomeStyle/fa.css" type="text/css">
    <script type="text/javascript" src="../../../layuiadmin/lib/zTree/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="../../../layuiadmin/lib/zTree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="../../../layuiadmin/lib/zTree/js/jquery.ztree.excheck.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card layui-form-item">
        <form class="layui-form layui-form-search layui-clear" action="">
            <div class="search-term">
                <label class="layui-form-label">品牌车型</label>
                <div class="layui-input-inline ">
                    <input type="text" name="" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="search-term">
                <label class="layui-form-label">发布时间</label>
                <div class="layui-input-inline">
                    <input name="start" id="date" class="layui-input Wdate" type="text"/>
                </div>
            </div>
            <div class="search-term">
                <label class="layui-form-label">起订数量</label>
                <div class="layui-input-inline ">
                    <select name="orderNub">
                        <option value="0">50</option>
                        <option value="1">100</option>
                    </select>
                </div>
            </div>
            <div class="search-term">
                <label class="layui-form-label">车源状态</label>
                <div class="layui-input-inline">
                    <select name="carStatus" lay-filter="aihao">
                        <option value="0">库存充足</option>
                        <option value="1">等待发货</option>
                    </select>
                </div>
            </div>
            <!--<div class="search-term">-->
                <!--<label class="layui-form-label">销售区域</label>-->
                <!--<div class="layui-input-inline">-->
                    <!--<select name="saleArea" lay-filter="aihao">-->
                        <!--<option value="0">全国</option>-->
                        <!--<option value="1">上海</option>-->
                    <!--</select>-->
                <!--</div>-->
            <!--</div>-->
            <div class="search-term">
                <label class="layui-form-label">销售区域</label>
                <div class="layui-input-inline">
                    <input id="citySel" type="text" class="layui-input" readonly value="" onclick="showMenu();" />
                </div>
                <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
                    <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
                </div>
            </div>
            <div class="search-term">
                <label class="layui-form-label">&nbsp;</label>
                <button class="layui-btn layui-bg-blue layui-btn-sm" lay-submit lay-filter="LAY-user-back-search">
                    <i class="layui-icon layui-icon-defined layui-icon-search"></i> 查询
                </button>
            </div>
        </form>
    </div>
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header">经销商采购车辆分析</div>
            <div class="layui-card-body layadmin-takerates">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-bg-blue layui-btn-sm" id="inputOptions"><i class="layui-icon layui-icon-defined layui-icon-add">录入车源</i></button>
                </div>
                <table class="layui-table" id="idTest" lay-filter="listTable"></table>
                <script type="text/html" id="barDemo">
                    <a class="layui-text-blue layui-btn-xs" lay-event="edit">编辑</a>
                    <a class="layui-text-green layui-btn-xs" lay-event="putOnShelf">上架</a>
                    <a class="layui-text-blue layui-btn-xs" lay-event="detail">详情</a>
                    <a class="layui-text-red layui-btn-xs" lay-event="soldOutShlef">下架</a>
                </script>
            </div>
        </div>
    </div>
</div>
<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        list: 'car_source/list', //list模块
    }).use(['index','list']);
</script>
<script type="text/javascript">
    var setting = {
        check: {
            enable: true,
            chkboxType: { "Y" : "ps", "N" : "ps" }
        },
        view: {
            dblClickExpand: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: beforeClick,
            onCheck: onCheck
        }
    };

    var zNodes =[
        {id:1, pId:0, name:"全国"},
        {id:2, pId:0, name:"上海"},
        {id:3, pId:0, name:"Shanghai"},
        {id:4, pId:0, name:"Hebei Province", open:true},
        {id:41, pId:4, name:"Shijiazhuang"},
        {id:42, pId:4, name:"Baoding"},
        {id:43, pId:4, name:"Handan"},
        {id:44, pId:4, name:"Chengde"},
        {id:5, pId:0, name:"Guangdong Province", open:true},
        {id:51, pId:5, name:"Guangzhou"},
        {id:52, pId:5, name:"Shenzhen"},
        {id:53, pId:5, name:"Dongguan"},
        {id:54, pId:5, name:"Fushan"},
        {id:6, pId:0, name:"Chongqing"},
        {id:6, pId:0, name:"Fujian Province", open:true},
        {id:61, pId:6, name:"Fuzhou"},
        {id:62, pId:6, name:"Xiamen"},
        {id:63, pId:6, name:"Quanzhou"},
        {id:64, pId:6, name:"Sanming"}
    ];

    function beforeClick(treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.checkNode(treeNode, !treeNode.checked, null, true);
        return false;
    }

    function onCheck(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getCheckedNodes(true),
            v = "";
        for (var i=0, l=nodes.length; i<l; i++) {
            v += nodes[i].name + ",";
        }
        if (v.length > 0 ) v = v.substring(0, v.length-1);
        var cityObj = $("#citySel");
        cityObj.attr("value", v);
    }

    function showMenu() {
        var cityObj = $("#citySel");
        var cityOffset = $("#citySel").offset();
        $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
        $("body").bind("mousedown", onBodyDown);
    }
    function hideMenu() {
        $("#menuContent").fadeOut("fast");
        $("body").unbind("mousedown", onBodyDown);
    }
    function onBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
            hideMenu();
        }
    }

    $(document).ready(function(){
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
    });
    //-->
</script>
</body>
</html>